<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
  <th:block th:include="include :: header('网站设置')" />
  <th:block th:include="include :: select2-css" />
  <th:block th:include="include :: bootstrap-select-css" />
  <th:block th:include="include :: img_upload_css" />
</head>
<body class="white-bg">
  <div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div class="tabs-container">
      <ul class="nav nav-tabs" id="config-title">
        <li class="active"><a data-toggle="tab" href="#normal" aria-expanded="true">网站设置</a>
        </li>
        <li class=""><a data-toggle="tab" href="#theme" aria-expanded="true">主题设置</a>
        </li>
        <li class=""><a data-toggle="tab" href="#page" aria-expanded="false">页面设置</a>
        </li>
        <li class=""><a data-toggle="tab" href="#about-me" aria-expanded="false">个人主页</a>
        </li>
        <li class=""><a data-toggle="tab" href="#other" aria-expanded="false">其它配置</a>
        </li>
        <li class=""><a data-toggle="tab" href="#siteMap" aria-expanded="false">SiteMap</a>
        </li>
      </ul>
      <div class="tab-content" th:with="webConfig=${@configTag.getConfigMapValue(configName)}">
        <!-- 网站常规 -->
        <div id="normal" class="tab-pane active">
          <div class="panel-body">
            <form class="form-horizontal m" id="form-normal">
              <div class="form-group">
                <label class="col-sm-3 control-label is-">主站：</label>
                <div class="col-sm-8">
                  <input class="disabled form-control" disabled
                    th:value="${#strings.equals(@configTag.getKey('themeConfig','oly.theme.used'),configName)? '是':'否'}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">网站域名：</label>
                <div class="col-sm-8">
                  <input name="oly.web.domain" th:value="${webConfig['oly.web.domain']}" class="form-control"
                    type="text">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">网站标题：</label>
                <div class="col-sm-8">
                  <input name="oly.web.title" th:value="${webConfig['oly.web.title']}" class="form-control" type="text">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">网站主页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.index" th:value="${webConfig['oly.web.index']}" class="form-control" type="text">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">作者：</label>
                <div class="col-sm-8">
                  <input name="oly.web.author" th:value="${webConfig['oly.web.author']}" class="form-control"
                    type="text">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">LOGO：</label>
                <div class="col-sm-8">
                  <div class="upload-content" id="logo">
                  </div>
                  <input name="oly.web.logo" th:value="${webConfig['oly.web.logo']}" class="form-control" type="hidden">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">ICO：</label>
                <div class="col-sm-8">
                  <div class="upload-content" id="ico">
                  </div>
                  <input name="oly.web.ico" th:value="${webConfig['oly.web.ico']}" class="form-control" type="hidden">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">网站版权：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.copyright" th:text="${webConfig['oly.web.copyright']}" class="form-control"
                    type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">页脚设置：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.footer" th:text="${webConfig['oly.web.footer']}" class="form-control"
                    type="text">
                                    </textarea>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- 主题 -->
        <div id="theme" class="tab-pane">
          <div class="panel-body">
            <form class="form-horizontal m" id="form-theme">
              <div class="form-group">
                <label class="col-sm-3 control-label disabled is-">主题名：</label>
                <div class="col-sm-8">
                  <input th:value="${configGroup}" class="form-control disabled" type="text" disabled />
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">支持类型：</label>
                <div class="col-sm-8">
                  <div class="input-group"
                    th:with="sus=${#strings.arraySplit(webConfig['oly.web.article.supportType'],',')}">
                    <select th:if="${sus!=null}" id="supportType" class="form-control select2-multiple" multiple>
                      <option th:each="dict : ${@dictTag.getType('cms_support_type')}" th:value="${dict.dictValue}"
                        th:text="${dict.dictLabel}" th:selected="${#arrays.contains(sus,dict.dictValue)}"></option>
                    </select>
                    <select th:if="${sus==null}" id="supportType" class="form-control select2-multiple" multiple>
                      <option th:each="dict : ${@dictTag.getType('cms_support_type')}" th:value="${dict.dictValue}"
                        th:text="${dict.dictLabel}"></option>
                    </select>
                    <input type="hidden" name="oly.web.article.supportType" />
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">开启评论：</label>
                <div class="col-sm-8">
                  <label class="toggle-switch switch-solid">
                    <input type="checkbox" id="oly.web.comment.enable"
                      th:checked="${webConfig['oly.web.comment.enable']}">
                    <input type="hidden" name="oly.web.comment.enable"
                      th:value="${webConfig['oly.web.comment.enable']}" />
                    <span></span>
                  </label>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">重建索引：</label>
                <div class="col-sm-8">
                  <div class="input-group">
                    <button type="button" class="btn btn-primary" onclick="buildArticleIndex()">刷新索引</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- 页面设置 -->
        <div id="page" class="tab-pane">
          <div class="panel-body">
            <form class="form-horizontal m" id="form-page">
              <div class="form-group">
                <label class="col-sm-3 control-label is-">首页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageIndex" th:value="${webConfig['oly.web.pageIndex']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">分类页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageCategory" th:value="${webConfig['oly.web.pageCategory']}"
                    class="form-control" type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">标签页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageTag" th:value="${webConfig['oly.web.pagepTag']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">排行榜：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageRank" th:value="${webConfig['oly.web.pageRank']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">导航页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageLinks" th:value="${webConfig['oly.web.pageLinks']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">时间线：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageTimeLine" th:value="${webConfig['oly.web.pageTimeLine']}"
                    class="form-control" type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">关于我本站：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageAbout" th:value="${webConfig['oly.web.pageAbout']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">联盟页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageUnion" th:value="${webConfig['oly.web.pageUnion']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">联系页：</label>
                <div class="col-sm-8">
                  <input name="oly.web.pageCallMe" th:value="${webConfig['oly.web.pageCallMe']}" class="form-control"
                    type="number" readonly>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- 关于本站 -->
        <div id="about-me" class="tab-pane">
          <div class="panel-body">
            <form class="form-horizontal m" id="form-about-me">
              <div class="form-group">
                <label class="col-sm-3 control-label is-">关于本站：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.about.website" th:text="${webConfig['oly.web.about.website']}"
                    class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">关于作者：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.about.author" th:text="${webConfig['oly.web.about.author']}"
                    class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">作者主页：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.about.index" th:text="${webConfig['oly.web.about.index']}"
                    class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">联系我：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.about.callme" th:text="${webConfig['oly.web.about.callme']}"
                    class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- 其他设置 -->
        <div id="other" class="tab-pane">
          <div class="panel-body">
            <form class="form-horizontal m" id="form-other">
              <div class="form-group">
                <label class="col-sm-3 control-label is-">自定义头部：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.head" th:text="${webConfig['oly.web.head']}" class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">自定义脚本：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.script" th:text="${webConfig['oly.web.script']}" class="form-control"
                    type="text">
                                    </textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-3 control-label is-">：</label>
                <div class="col-sm-8">
                  <textarea name="oly.web.post.copyright" th:text="${webConfig['oly.web.post.copyright']}"
                    class="form-control" type="text">
                                    </textarea>
                </div>
              </div>
            </form>
          </div>
        </div>
        <!-- siteMap -->
        <div id="siteMap" class="tab-pane">
          <div class="panel-body form-horizontal m">
            <div class="form-group">
              <label class="col-sm-3 control-label is-">生成所有：</label>
              <div class="col-sm-3 control-label is-">
                <span class="btn btn-w-m btn-primary center-block" onclick="siteMapAll()">生成</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label is-">依据时间：</label>
              <div class="col-sm-3">
                <div class="input-group date">
                  <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                  <input type="text" class="time-input form-control" id="datetimepicker" placeholder="yyyy-MM-dd">
                </div>
              </div>
              <div class="col-sm-3">
                <span class="btn btn-w-m btn-primary center-block" onclick="siteMapByTime()">生成</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <button type="button" class="btn btn-w-m btn-primary center-block" id="submit-btn">修改</button>
    </div>
  </div>
  <th:block th:include="include :: footer" />
  <th:block th:include="include :: select2-js" />
  <th:block th:include="include::bootstrap-select-js" />
  <th:block th:include="include :: img_upload_js" />
  <script type="text/javascript" th:inline="javascript">
    var prefix = ctx + "cms/theme";
    var toolPrefix = ctx + "cms/tool";
    var myForm = "form-normal";
    $('#config-title a').click(function (e) {
      e.preventDefault();
      $(this).tab('show');
      myForm = $(this).attr('href').replace("#", "form-");
      if (myForm == 'form-siteMap') {
        $("#submit-btn").hide();
      }
      else {
        $("#submit-btn").show();
      }
    });

    /*栏目管理-新增-选择菜单树*/
    $("#form-page input").click(function () {
      var ui = $(this);
      var url = ctx + "cms/column/selectColumnTree/0?visible=1";
      var options = {
        title: '栏目选择',
        width: "380",
        url: url,
        callBack: function (index, layero) {
          var body = $.modal.getChildFrame(index);
          $(ui).val(body.find('#treeId').val());
          $.modal.close(index);
        }
      };
      $.modal.openOptions(options);
    })



    function setOpen() {
      $("input[name='oly.web.comment.enable']").val($("input[id='oly.web.comment.enable']").is(':checked'));
      $("input[name='oly.web.article.supportType']").val($.form.selectSelects("supportType"));
    }
    function submitHandler() {
      setOpen();
      var data = $("#" + myForm).serializeArray();
      data.push({ "name": "configGroup", "value": [[${ configName }]] });
      $.operate.saveModal(prefix + "/updateByGk", data);

    }

    function buildArticleIndex() {
      $.operate.saveModal(ctx + "cms/theme/buildArticleIndex/" + [[${ configName }]]);
    }

    function siteMapAll() {
      $.operate.saveModal(toolPrefix + "/siteMapXml/" + [[${ configGroup }]]);
    };
    function siteMapByTime() {
      $.operate.saveModal(toolPrefix + "/siteMapXmlByByBeginTime/" + [[${ configGroup }]], { 'beginTime': $('#datetimepicker').val() });
    }
    $("#submit-btn").click(function () {
      submitHandler();
    })

  </script>
   
  <script type="text/javascript" th:inline="javascript">
    var uploadUrl = ctx + "oly/oss/upload";
    var icoConfig = { element: "ico", maxNum: 1, uploadUrl: uploadUrl };
    if ($("input[name='oly.web.ico']").val().length > 0) {
      icoConfig.imgSrc = [$("input[name='oly.web.ico']").val()];
    }

    $.imageUpload.init(icoConfig);
    $("#ico").on("imgUploaded", function (e, msg) {
      $("input[name='oly.web.ico']").val(msg.data.domain + msg.data.fk);
    });

    $("#ico").on("imgRemove", function (e, msg) {
      $("input[name='oly.web.ico']").val("");
    });

    var logoConfig = { element: "logo", maxNum: 1, uploadUrl: uploadUrl };
    if ($("input[name='oly.web.logo']").val().length > 0) {
      logoConfig.imgSrc = [$("input[name='oly.web.logo']").val()];
    }
    $.imageUpload.init(logoConfig);
    $("#logo").on("imgUploaded", function (e, msg) {
      $("input[name='oly.web.logo']").val(msg.data.domain + msg.data.fk);
    });
    $("#logo").on("imgRemove", function (e, msg) {
      $("input[name='oly.web.logo']").val("");
    });
  </script>


</body>

</html>